/*
 * Copyright (C) 2021 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.xuexiang.templateproject.fragment.news;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.renderscript.ScriptGroup;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.webkit.WebView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;

import com.github.mikephil.charting.animation.Easing;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.PieData;
import com.github.mikephil.charting.data.PieDataSet;
import com.github.mikephil.charting.data.PieEntry;
import com.github.mikephil.charting.formatter.PercentFormatter;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
import com.github.mikephil.charting.utils.ColorTemplate;
import com.github.mikephil.charting.utils.MPPointF;
import com.xuexiang.templateproject.R;
import com.xuexiang.templateproject.activity.MainActivity;
import com.xuexiang.templateproject.core.BaseActivity;
import com.xuexiang.templateproject.core.BaseFragment;
import com.xuexiang.templateproject.core.BroadCastManager;
import com.xuexiang.templateproject.databinding.ActivityMainBinding;
import com.xuexiang.templateproject.databinding.FragmentGridItemBinding;
import com.xuexiang.xhttp2.XHttp;
import com.xuexiang.xhttp2.callback.impl.IProgressResponseCallBack;
import com.xuexiang.xhttp2.subsciber.ProgressLoadingSubscriber;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xrouter.annotation.AutoWired;
import com.xuexiang.xrouter.launcher.XRouter;
import com.xuexiang.xui.widget.imageview.IconImageView;
import com.xuexiang.xui.widget.imageview.RadiusImageView;
import com.xuexiang.xutil.file.FileUtils;
import com.xuexiang.xutil.tip.ToastUtils;

import org.w3c.dom.Text;

import java.io.IOException;
import java.time.MonthDay;
import java.util.ArrayList;
import java.util.Objects;

/**
 * @author xuexiang
 * @since 2021/6/30 1:21 AM
 */
@Page
public class GridItemFragment extends BaseFragment<FragmentGridItemBinding> {

    public static final String KEY_TITLE_NAME = "title_name";

    /**
     * 自动注入参数，不能是private
     */
    @AutoWired(name = KEY_TITLE_NAME)
    String title;

    @NonNull
    @Override
    protected FragmentGridItemBinding viewBindingInflate(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, boolean attachToRoot) {
        return FragmentGridItemBinding.inflate(inflater, container, attachToRoot);
    }

    @Override
    protected void initArgs() {
        // 自动注入参数必须在initArgs里进行注入
        XRouter.getInstance().inject(this);
    }

    @Override
    protected String getPageTitle() {
        return title;
    }


    @Override
    protected void initViews() {
        TextView feeltext=findViewById(R.id.feeltext);
        IconImageView sad=findViewById(R.id.sad);
        IconImageView happy=findViewById(R.id.happy);
        IconImageView normal=findViewById(R.id.normal);
        IconImageView angry=findViewById(R.id.angry);
        feeltext.setVisibility(View.GONE);
        sad.setVisibility(View.GONE);
        happy.setVisibility(View.GONE);
        normal.setVisibility(View.GONE);
        angry.setVisibility(View.GONE);
        RadiusImageView heart=findViewById(R.id.heart);
        Animation animation = AnimationUtils.loadAnimation(getContext(),R.anim.breath);
        heart.startAnimation(animation);
        heart.setClickable(true);
        TextView jiance = findViewById(R.id.jiance);
        jiance.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        jiance.setAnimation(AnimationUtils.loadAnimation(getContext(),R.anim.slin));
        heart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                heart.clearAnimation();
                Intent intent = new Intent();
                intent.putExtra("opt", "stop");
                intent.setAction("p");
                BroadCastManager.getInstance().sendBroadCast(getActivity(),intent);
                requireActivity().onBackPressed();

                ToastUtils.toast("已退出监测,祝您身体健康!");
            }
        });
    }

  


}
